// pages/Audit_details/Audit_details.js
var call = require("../../utils/ajax.js")
var host = 'http://localhost:8085/';
Page({

    /**
     * 页面的初始数据
     */
    data: {
        adpot_message: [],
        adopt_id: "",
        level: "",
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function(options) {
        console.log(options)
        var adopt_id = options.adopt_id;
        var that = this;
        that.setData({
            adopt_id: adopt_id
        })
        console.log(this.data.adopt_id)
        var url = "Adopt/selectAdoptOne?adopt_id=" + adopt_id
        call.getData1(url, function(res) {
            console.log(res)
            that.setData({
                adpot_message: res.date
            })
            var hh = res.date.income_level;
            var num = "";

            function ad(hh) {
                switch (hh) {
                    case 0:
                        num = "0-2000";
                        that.setData({
                            level: num
                        })
                        console.log(that.data.level);
                        break;
                    case 1:
                        console.log(that.data.level);
                        num = "2000-5000";
                        that.setData({
                            level: num
                        })
                        break;
                    case 2:
                        console.log(that.data.level);
                        num = "5000-10000";
                        that.setData({
                            level: num
                        })
                        break;
                    case 3:
                        num = "10000以上";
                        console.log(that.data.level);
                        that.setData({
                            level: num
                        })
                        break;
                        // default:
                        //    默认代码块
                }
                console.log("ss")
                console.log("ssc")
            }
            ad(hh);
        })
    },

    pass: function(e) {
        console.log(e)
        wx.showModal({
            title: '提示',
            content: '确认是否通过申请',
            success: function(res) {
                if (res.confirm) {
                    var apple_id = e.currentTarget.id;
                    var url2 = "Adopt/passAdoptPet?adopt_id=" + apple_id
                    call.request1(url2, {}, function(res) {
                        console.log(res)
                        wx.showToast({
                            title: '操作成功',
                            icon: 'success', //如果要纯文本，不要icon，将值设为'none'
                            duration: 200
                        })
                        setTimeout(() => {
                            wx.navigateBack({
                                delta: 3, // 回退前 delta(默认为1) 页面
                            })
                        }, 200)
                    })
                } else if (res.cancel) {
                    console.log('用户点击取消')
                }
            }
        })



    },
    unpass: function(e) {
        wx.showModal({
            title: '提示',
            content: '确认是否不通过申请',
            success: function(res) {
                if (res.confirm) {
                    var apple_id = e.currentTarget.id;
                    var url3 = "Adopt/updateAdoptStateWei?adopt_id=" + apple_id
                    call.getData1(url3, function(res) {
                        console.log(res)
                        wx.showToast({
                            title: '操作成功',
                            icon: 'success', //如果要纯文本，不要icon，将值设为'none'
                            duration: 200
                        })
                        setTimeout(() => {
                            wx.navigateBack({
                                delta: 3, // 回退前 delta(默认为1) 页面
                            })
                        }, 200)
                    })
                } else if (res.cancel) {
                    console.log('用户点击取消')
                }
            }
        })
        console.log(e)

    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function() {

    }
})